﻿<UserControl x:Class="UML_Creator.View.FullLineEdgeUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:umlmdl="clr-namespace:UML_Creator.Model;assembly=UML_Creator.Model"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <umlmdl:LineConverter x:Key="LineConverter"/>
    </UserControl.Resources>
    <Canvas>
        <Path Stroke="{Binding Colour}" Opacity="{Binding Opacity}" StrokeThickness="1">
            <Path.Data>
                <PathGeometry>
                    <PathGeometry.Figures>
                        <MultiBinding Converter="{StaticResource LineConverter}">
                            <Binding Path="EndA.X" />
                            <Binding Path="EndA.Y" />
                            <Binding Path="EndA.Width" />
                            <Binding Path="EndA.Height" />
                            <Binding Path="EndB.X" />
                            <Binding Path="EndB.Y" />
                            <Binding Path="EndB.Width" />
                            <Binding Path="EndB.Height" />
                        </MultiBinding>
                    </PathGeometry.Figures>
                </PathGeometry>
            </Path.Data>
        </Path>


        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDown">
                <cmd:EventToCommand Command="{Binding DataContext.MouseClickEdgeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" PassEventArgsToCommand="True"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </Canvas>
</UserControl>
